package com.itheima.health.controller;

import com.itheima.health.common.MessageConst;
import com.itheima.health.entity.PageResult;
import com.itheima.health.entity.QueryPageBean;
import com.itheima.health.entity.Result;
import com.itheima.health.pojo.Setmeal;
import com.itheima.health.service.SetMealService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 山外小王
 * @Description 体检套餐管理
 * @Date 2024/04/15/15:55
 */
@RestController
@RequestMapping("/setmeal")
public class SetMealController {

    @Autowired
    private SetMealService setMealService;
    @GetMapping("/findPage")
    public Result findPage (QueryPageBean queryPageBean){
        PageResult pageResult = setMealService.findPage(queryPageBean);
        return new Result(true, MessageConst.ACTION_SUCCESS,pageResult);
    }
    @PostMapping("/add")
    public Result add(@RequestBody Setmeal setmeal,Integer[] checkgroupIds){
        setMealService.add(setmeal,checkgroupIds);
        return new Result(true,MessageConst.ADD_SETMEAL_SUCCESS,null);
    }
    @GetMapping("/findById")
    public Result findById(Integer id){
        Setmeal setmeal = setMealService.findById(id);
        return new Result(true,MessageConst.ACTION_SUCCESS,setmeal);
    }
    @PostMapping("/edit")
    public Result edit(@RequestBody Setmeal setmeal ,Integer[] checkGroupIds){
        setMealService.edit(setmeal,checkGroupIds);
        return new Result(true,"编辑套餐成功",null);
    }

    @PostMapping("/deleteSetmealById")
    public Result deleteSetmealById(Integer id){
        setMealService.deleteSetmealById(id);
        return new Result(true,"删除套餐成功",null);
    }
}
